package cn.edu.fudan.autoparser;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class NetEaseAutoHTMLParser extends AutoHTMLParser {

	public NetEaseAutoHTMLParser(String basicURL, String subURL) {
		super(basicURL, subURL);
	}

	@Override
	public void getHTML() throws IOException {
		Document doc = null;
		doc=Jsoup.connect(basicURl+subURL).get();
		Elements elements=doc.getElementsByClass("ep-pages-all");
		if(elements.size()>0){
			String newURL=elements.get(0).attr("href");
			doc=Jsoup.connect(newURL).get();
		}
		HTML=doc;
	}

	@Override
	public void parseHTML() {
		Elements title=HTML.getElementsByTag("h1");
		Elements content = HTML.getElementsByAttributeValue("id", "endText");
		this.tiltle=title.get(0).text();
		for(Element element:content){
			this.content+=element.text();
		}
	}

}
